<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>第十节：WXS语法 | 微信小程序</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../di-san-zhang-ff1a-chang-yong-zu-jian.html" />
    
    
    <link rel="prev" href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-jiu-jie-ff1a-page-dui-xiang.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="2.9"
        data-chapter-title="第十节：WXS语法"
        data-filepath="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-shi-zhang-ff1a-wxs-yu-fa.md"
        data-basepath=".."
        data-revision="Tue Feb 12 2019 17:48:38 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="chapter1.html">
            
                
                    <a href="../chapter1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        第一章：小程序前奏
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="chapter1/di-yi-jie-ff1a-ren-shi-xiao-cheng-xu.html">
            
                
                    <a href="../chapter1/di-yi-jie-ff1a-ren-shi-xiao-cheng-xu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        第一节：认识小程序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="chapter1/di-er-jie-ff1a-zhun-bei-gong-zuo.html">
            
                
                    <a href="../chapter1/di-er-jie-ff1a-zhun-bei-gong-zuo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        第二节：准备工作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="chapter1/di-san-jie-ff1a-kai-fa-gong-ju-jie-shao.html">
            
                
                    <a href="../chapter1/di-san-jie-ff1a-kai-fa-gong-ju-jie-shao.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        第三节：开发工具介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="chapter1/di-liu-jie-ff1a-wxss-yu-fa.html">
            
                
                    <a href="../chapter1/di-liu-jie-ff1a-wxss-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        第六节：WXSS语法
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        第二章：小程序基础
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-yi-jie-ff1a-kuang-jia-jie-shao.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-yi-jie-ff1a-kuang-jia-jie-shao.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        第一节：项目结构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-er-jie-ff1a-wxml-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-er-jie-ff1a-wxml-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        第二节：配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-san-jie-ff1a-wxml-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-san-jie-ff1a-wxml-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        第三节：WXML语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-si-jie-ff1a-wxss-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-si-jie-ff1a-wxss-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        第五节：事件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-liu-jie-ff1a-wxss-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-liu-jie-ff1a-wxss-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        第六节：WXSS语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-qi-jie-ff1a-flex-bu-ju.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-qi-jie-ff1a-flex-bu-ju.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        第七节：flex布局
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-bajie-ff1a-app-sheng-ming-zhou-qi.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-bajie-ff1a-app-sheng-ming-zhou-qi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        第八节：APP对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-jiu-jie-ff1a-page-dui-xiang.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-jiu-jie-ff1a-page-dui-xiang.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        第九节：Page对象
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2.9" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-shi-zhang-ff1a-wxs-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-shi-zhang-ff1a-wxs-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        第十节：WXS语法
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="di-san-zhang-ff1a-chang-yong-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        第三章：常用组件
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-yi-jie-ff1a-shi-tu-rong-qi-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-yi-jie-ff1a-shi-tu-rong-qi-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        第一节：scroll-view组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-er-jieff1a-swiper-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-er-jieff1a-swiper-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        第二节：swiper组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-san-jie-ff1a-movable-view-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-san-jie-ff1a-movable-view-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        第三节：movable-view组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-sijie-ff1a-icon-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-sijie-ff1a-icon-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        第四节：icon组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-wu-jie-ff1a-text-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-wu-jie-ff1a-text-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        第五节：text组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-liu-jie-ff1a-input-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-liu-jie-ff1a-input-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        第六节：input组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/zi-ding-yi-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/zi-ding-yi-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        自定义组件
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" >
            
            <span><b>4.</b> 第四章：小程序API</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="di-yi-jie-ff1a-wang-luo-qing-qiu-api.html">
            
                
                    <a href="../di-yi-jie-ff1a-wang-luo-qing-qiu-api.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        第一节：网络请求API
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="di-liu-zhang-ff1a-es6-yu-fa.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        第五章：ES6语法
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-yi-jie-ff1a-shi-yao-shi-es6-yu-fa.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-yi-jie-ff1a-shi-yao-shi-es6-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        第一节：什么是ES6语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-er-jie-ff1a-es6-yu-fa.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-er-jie-ff1a-es6-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        第二节：定义变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-san-jie-ff1a-han-shu.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-san-jie-ff1a-han-shu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        第三节：函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-si-jie-ff1a-lei.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-si-jie-ff1a-lei.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        第四节：类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-wu-jie-ff1a-mo-kuai.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-wu-jie-ff1a-mo-kuai.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        第五节：模块
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="di-wu-zhang-ff1a-yun-kai-fa.html">
            
                
                    <a href="../di-wu-zhang-ff1a-yun-kai-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        第六章：云开发
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="di-yi-jie-ff1a-shi-yao-shi-yun-kai-fa.html">
            
                
                    <a href="../di-yi-jie-ff1a-shi-yao-shi-yun-kai-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        第一节：什么是云开发
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="di-er-jie-ff1a-zhu-ce-wei-xin-xiao-cheng-xu.html">
            
                
                    <a href="../di-er-jie-ff1a-zhu-ce-wei-xin-xiao-cheng-xu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        第二节：注册微信小程序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="di-san-jie-ff1a-kai-tong-yun-kai-fa.html">
            
                
                    <a href="../di-san-jie-ff1a-kai-tong-yun-kai-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        第三节：开通云开发
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="di-si-jie-ff1a-shu-ju-ku.html">
            
                
                    <a href="../di-si-jie-ff1a-shu-ju-ku.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        第四节：数据库准备
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="di-wu-jie-ff1a-shu-ju-ku-cao-zuo.html">
            
                
                    <a href="../di-wu-jie-ff1a-shu-ju-ku-cao-zuo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        第五节：数据库操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="di-liu-jie-ff1a-command-zhi-ling.html">
            
                
                    <a href="../di-liu-jie-ff1a-command-zhi-ling.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        第六节：command指令
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="di-qi-jie-ff1a-gao-ji-cha-xun.html">
            
                
                    <a href="../di-qi-jie-ff1a-gao-ji-cha-xun.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        第七节：高级查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="di-ba-jie-ff1a-wen-jian-shang-chuan.html">
            
                
                    <a href="../di-ba-jie-ff1a-wen-jian-shang-chuan.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        第八节：文件操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="di-jiu-jie-ff1a-node-huan-jing-da-jian.html">
            
                
                    <a href="../di-jiu-jie-ff1a-node-huan-jing-da-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.9.</b>
                        
                        第九节：node环境搭建
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="di-shi-jie-ff1a-yun-han-shu.html">
            
                
                    <a href="../di-shi-jie-ff1a-yun-han-shu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.10.</b>
                        
                        第十节：云函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="di-shi-yi-jie-ff1a-yun-han-shu-jian-ce-nei-rong-an-quan.html">
            
                
                    <a href="../di-shi-yi-jie-ff1a-yun-han-shu-jian-ce-nei-rong-an-quan.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.11.</b>
                        
                        第十一节：检测内容安全
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.12" data-path="di-shi-er-jie-ff1a-yun-han-shu-tu-pian-jian-huang.html">
            
                
                    <a href="../di-shi-er-jie-ff1a-yun-han-shu-tu-pian-jian-huang.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.12.</b>
                        
                        第十二节：图片鉴黄
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.13" data-path="di-shi-san-jie-ff1a-yong-hu-shou-quan.html">
            
                
                    <a href="../di-shi-san-jie-ff1a-yong-hu-shou-quan.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.13.</b>
                        
                        第十三节：用户授权
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.14" data-path="di-shi-si-jie-ff1a-qi-ta-shou-quan-fang-shi.html">
            
                
                    <a href="../di-shi-si-jie-ff1a-qi-ta-shou-quan-fang-shi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.14.</b>
                        
                        第十四节：其他授权方式
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >微信小程序</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="wxs&#x8BED;&#x6CD5;&#xFF1A;">WXS&#x8BED;&#x6CD5;&#xFF1A;</h1>
<p>&#x5728;&#x4F20;&#x7EDF;&#x7684;&#x7F51;&#x9875;&#x5F00;&#x53D1;&#x4E2D;&#xFF0C;<code>HTML</code>&#x4E2D;&#x662F;&#x53EF;&#x4EE5;&#x5199;<code>JavaScript</code>&#x4EE3;&#x7801;&#x7684;&#xFF0C;&#x800C;&#x5728;&#x5C0F;&#x7A0B;&#x5E8F;&#x4E2D;&#xFF0C;&#x662F;&#x4E0D;&#x5141;&#x8BB8;&#x5728;<code>WXML</code>&#x6587;&#x4EF6;&#x4E2D;&#x5199;<code>JavaScript</code>&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x6709;&#x4E9B;&#x65F6;&#x5019;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x5728;<code>wxml</code>&#x4E2D;&#x5B9E;&#x73B0;&#x4E00;&#x4E9B;&#x903B;&#x8F91;&#x7684;&#x5904;&#x7406;&#x3002;&#x6BD4;&#x5982;&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x6211;&#x4EEC;&#x6E32;&#x67D3;&#x4E00;&#x4E2A;&#x6570;&#x5B57;&#x5230;<code>wxml</code>&#x4E2D;&#xFF0C;&#x5728;<code>wxml</code>&#x6587;&#x4EF6;&#x4E2D;&#x6839;&#x636E;&#x8FD9;&#x4E2A;&#x6570;&#x5B57;&#x6765;&#x6E32;&#x67D3;&#x5177;&#x4F53;&#x661F;&#x671F;&#x51E0;&#x3002;&#x8FD9;&#x65F6;&#x5019;&#x901A;&#x8FC7;<code>wxml</code>&#x6587;&#x4EF6;&#x4E2D;&#x5C31;&#x505A;&#x4E0D;&#x4E86;&#x4E86;&#xFF0C;&#x6216;&#x8005;&#x53EA;&#x80FD;&#x5728;<code>JavaScript</code>&#x5148;&#x8BA1;&#x7B97;&#x597D;&#x518D;&#x6E32;&#x67D3;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">view</span>&gt;</span>{{weekday}}<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
<pre><code class="lang-javascript">Page({
    data: {
        day: <span class="hljs-number">1</span>
    },
    onLoad: <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">options</span>) </span>{
      <span class="hljs-keyword">var</span> weekday = <span class="hljs-string">&quot;&quot;</span>;
      <span class="hljs-keyword">switch</span>(<span class="hljs-keyword">this</span>.data.day){
        <span class="hljs-keyword">case</span> <span class="hljs-number">1</span>:
          weekday = <span class="hljs-string">&quot;&#x661F;&#x671F;&#x4E00;&quot;</span>;
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-number">2</span>:
          weekday = <span class="hljs-string">&quot;&#x661F;&#x671F;&#x4E8C;&quot;</span>;
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-number">3</span>:
          weekday = <span class="hljs-string">&quot;&#x661F;&#x671F;&#x4E09;&quot;</span>;
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-number">4</span>:
          weekday = <span class="hljs-string">&quot;&#x661F;&#x671F;&#x56DB;&quot;</span>;
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-number">5</span>:
          weekday = <span class="hljs-string">&quot;&#x661F;&#x671F;&#x4E94;&quot;</span>;
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-number">6</span>:
          weekday = <span class="hljs-string">&quot;&#x661F;&#x671F;&#x516D;&quot;</span>;
          <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">case</span> <span class="hljs-number">7</span>:
          weekday = <span class="hljs-string">&quot;&#x661F;&#x671F;&#x5929;&quot;</span>;
          <span class="hljs-keyword">break</span>;
      }
      <span class="hljs-keyword">this</span>.setData({
        weekday: weekday
      });
    }
});
</code></pre>
<p>&#x8FD9;&#x65F6;&#x5019;&#x5C0F;&#x7A0B;&#x5E8F;&#x5C31;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x8BED;&#x6CD5;&#x53EB;&#x505A;<code>wxs</code>&#x53EF;&#x4EE5;&#x5E2E;&#x6211;&#x4EEC;&#x76F4;&#x63A5;&#x5728;<code>wxml</code>&#x4E2D;&#x89E3;&#x51B3;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">wxs</span> <span class="hljs-attribute">module</span>=<span class="hljs-value">&quot;index&quot;</span>&gt;</span>
  var getWeekDay = function(day){
    var weekday = &quot;&quot;;
    switch(day){
      case 1:
        weekday = &quot;&#x661F;&#x671F;&#x4E00;&quot;;
        break;
      case 2:
        weekday = &quot;&#x661F;&#x671F;&#x4E8C;&quot;;
        break;
      case 3:
        weekday = &quot;&#x661F;&#x671F;&#x4E09;&quot;;
        break;
      case 4:
        weekday = &quot;&#x661F;&#x671F;&#x56DB;&quot;;
        break;
      case 5:
        weekday = &quot;&#x661F;&#x671F;&#x4E94;&quot;;
        break;
      case 6:
        weekday = &quot;&#x661F;&#x671F;&#x516D;&quot;;
        break;
      case 7:
        weekday = &quot;&#x661F;&#x671F;&#x5929;&quot;;
        break;
    }
    return weekday;
  }
  module.exports.getWeekDay = getWeekDay;
<span class="hljs-tag">&lt;/<span class="hljs-title">wxs</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">view</span>&gt;</span>{{index.getWeekDay(day)}}<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
<p><code>wxs</code>&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;<code>javascript</code>&#x7684;&#x4E00;&#x4E2A;&#x9609;&#x5272;&#x7248;&#x672C;&#x3002;&#x4F7F;&#x7528;<code>wxs</code>&#x7684;&#x597D;&#x5904;&#x5982;&#x4E0B;&#xFF1A;  </p>
<ol>
<li>&#x5728;<code>iOS</code>&#x4E0A;&#xFF0C;&#x5728;<code>wxs</code>&#x4E2D;&#x4EE3;&#x7801;&#x6267;&#x884C;&#x6548;&#x7387;&#x662F;&#x5728;<code>js</code>&#x4E2D;&#x6267;&#x884C;&#x7684;<code>2-20</code>&#x500D;&#x3002;  </li>
<li>&#x53EF;&#x4EE5;&#x628A;&#x66F4;&#x591A;&#x7684;&#x903B;&#x8F91;&#x5728;<code>wxml</code>&#x6587;&#x4EF6;&#x4E2D;&#x5B8C;&#x6210;&#x3002;</li>
</ol>
<h2 id="wxs&#x4EE3;&#x7801;&#xFF1A;">wxs&#x4EE3;&#x7801;&#xFF1A;</h2>
<p><code>wxs</code>&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x5199;&#x5728;<code>wxml</code>&#x6587;&#x4EF6;&#x4E2D;&#x3002;&#x4E5F;&#x53EF;&#x4EE5;&#x5355;&#x72EC;&#x653E;&#x5728;<code>.wxs</code>&#x540E;&#x7F00;&#x7684;&#x6587;&#x4EF6;&#x4E2D;&#x3002;&#x5982;&#x679C;&#x662F;&#x5199;&#x5728;<code>wxml</code>&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x5219;&#x5FC5;&#x987B;&#x8981;&#x653E;&#x5728;<code>wxs</code>&#x6807;&#x7B7E;&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x662F;&#x5355;&#x72EC;&#x653E;&#x5728;<code>.wxs</code>&#x540E;&#x7F00;&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x5C31;&#x4E0D;&#x9700;&#x8981;&#x653E;&#x5728;<code>wxs</code>&#x6807;&#x7B7E;&#x4E2D;&#x4E86;&#x3002;&#x5E76;&#x4E14;&#x5FC5;&#x987B;&#x8981;&#x7ED9;<code>wxs</code>&#x4E00;&#x4E2A;<code>module</code>&#x5C5E;&#x6027;&#xFF0C;&#x7528;&#x6765;&#x6807;&#x8BB0;&#x8FD9;&#x4E2A;<code>wxs</code>&#x7684;&#x540D;&#x79F0;&#x3002;&#x4EE5;&#x4E0B;&#x662F;&#x4F7F;&#x7528;<code>.wxs</code>&#x7684;&#x8BED;&#x6CD5;&#x3002;</p>
<pre><code class="lang-html">// /pages/tools.wxs&#x6587;&#x4EF6;
<span class="hljs-tag">&lt;<span class="hljs-title">wxs</span> <span class="hljs-attribute">module</span>=<span class="hljs-value">&quot;tools&quot;</span>&gt;</span>
var person = {
  &quot;username&quot;: &quot;zhiliao&quot;,
  &quot;age&quot;: 18
}
module.exports = person;
<span class="hljs-tag">&lt;/<span class="hljs-title">wxs</span>&gt;</span>
</code></pre>
<p>&#x4EE5;&#x540E;&#x60F3;&#x4F7F;&#x7528;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5C31;&#x76F4;&#x63A5;&#x5728;<code>wxml</code>&#x4EE3;&#x7801;&#x4E2D;&#x4F7F;&#x7528;<code>wxs</code>&#x6765;&#x5F15;&#x7528;<code>wxs</code>&#x6587;&#x4EF6;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-wxml"><wxs src="./../tools.wxs" module="tools">
<view> {{tools.username}} </view>
</wxs></code></pre>
<p>&#x53E6;&#x5916;&#xFF0C;&#x6211;&#x4EEC;&#x5728;<code>wxs</code>&#x4E2D;&#x5199;&#x5B8C;&#x4E86;&#x4EE3;&#x7801;&#xFF0C;&#x8FD8;&#x9700;&#x8981;&#x5BFC;&#x51FA;&#x624D;&#x80FD;&#x591F;&#x4F7F;&#x7528;&#x3002;&#x4F7F;&#x7528;<code>module.exports</code>&#x5373;&#x53EF;&#x5BFC;&#x51FA;&#x3002;</p>
<h2 id="require&#x51FD;&#x6570;&#xFF1A;">require&#x51FD;&#x6570;&#xFF1A;</h2>
<p>&#x5982;&#x679C;&#x5728;&#x4E00;&#x4E2A;<code>wxs</code>&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x60F3;&#x5F15;&#x7528;&#x53E6;&#x5916;&#x4E00;&#x4E2A;<code>wxs</code>&#x6587;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>require</code>&#x51FD;&#x6570;&#x5F15;&#x7528;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// tools.wxs</span>
<span class="hljs-keyword">var</span> person = {
  <span class="hljs-string">&quot;username&quot;</span>: <span class="hljs-string">&quot;zhiliao&quot;</span>,
  <span class="hljs-string">&quot;age&quot;</span>: <span class="hljs-number">18</span>
}

<span class="hljs-built_in">module</span>.exports.person = person;
</code></pre>
<p>&#x5728;&#x53E6;&#x5916;&#x4E00;&#x4E2A;<code>wxs</code>&#x6587;&#x4EF6;&#x4E2D;&#x5C31;&#x53EF;&#x4EE5;&#x8FDB;&#x884C;&#x5F15;&#x7528;&#x4E86;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> tools = <span class="hljs-built_in">require</span>(<span class="hljs-string">&quot;./tools.wxs&quot;</span>);
<span class="hljs-built_in">console</span>.log(tools.person.username);
</code></pre>
<h2 id="&#x53D8;&#x91CF;&#xFF1A;">&#x53D8;&#x91CF;&#xFF1A;</h2>
<p>&#x53D8;&#x91CF;&#x7684;&#x5B9A;&#x4E49;&#x8DDF;<code>javascript</code>&#x4E00;&#x81F4;&#x3002;&#x8BF7;&#x67E5;&#x770B;&#xFF1A;<code>https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/02variate.html</code>&#x3002;</p>
<h2 id="&#x6CE8;&#x91CA;&#xFF1A;">&#x6CE8;&#x91CA;&#xFF1A;</h2>
<p>&#x6CE8;&#x91CA;&#x4F7F;&#x7528;<code>/*&#x6CE8;&#x91CA;*/</code>&#x4EE5;&#x53CA;<code>//&#x6CE8;&#x91CA;</code>&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x53E6;&#x5916;&#x589E;&#x52A0;&#x4E86;&#x4E00;&#x79CD;<code>/* xxx</code>&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x4F1A;&#x628A;<code>/*</code>&#x540E;&#x7684;&#x6240;&#x6709;&#x4EE3;&#x7801;&#x5168;&#x90E8;&#x90FD;&#x6CE8;&#x91CA;&#x4E86;&#x3002;</p>
<h2 id="&#x8FD0;&#x7B97;&#x7B26;&#xFF1A;">&#x8FD0;&#x7B97;&#x7B26;&#xFF1A;</h2>
<p>yu&#x4F60;&#x7B97;&#x7B26;&#x8DDF;<code>javascript</code>&#x4E00;&#x81F4;&#x3002;&#x8BF7;&#x67E5;&#x770B;&#xFF1A;<code>https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/04operator.html</code>&#x3002;</p>
<h2 id="&#x8BED;&#x53E5;&#xFF1A;">&#x8BED;&#x53E5;&#xFF1A;</h2>
<p>&#x5305;&#x62EC;&#x6709;<code>if</code>&#x8BED;&#x53E5;&#x3001;<code>for</code>&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x3001;<code>while</code>&#x5FAA;&#x73AF;&#x8BED;&#x53E5;&#x3001;<code>switch</code>&#x5206;&#x652F;&#x8BED;&#x53E5;&#x3002;&#x5177;&#x4F53;&#x67E5;&#x770B;&#xFF1A;<code>https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/05statement.html</code>&#x3002;</p>
<h2 id="&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF1A;">&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF1A;</h2>
<ul>
<li>number &#xFF1A; &#x6570;&#x503C;</li>
<li>string &#xFF1A;&#x5B57;&#x7B26;&#x4E32;</li>
<li>boolean&#xFF1A;&#x5E03;&#x5C14;&#x503C;</li>
<li>object&#xFF1A;&#x5BF9;&#x8C61;</li>
<li>function&#xFF1A;&#x51FD;&#x6570;</li>
<li>array : &#x6570;&#x7EC4;</li>
<li>date&#xFF1A;&#x65E5;&#x671F;</li>
<li>regexp&#xFF1A;&#x6B63;&#x5219;</li>
</ul>
<p>&#x5176;&#x4E2D;&#x6BCF;&#x79CD;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x7684;&#x65B9;&#x6CD5;&#x8BF7;&#x53C2;&#x8003;&#xFF1A;<code>https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/06datatype.html</code>&#x3002;</p>
<h2 id="&#x5185;&#x7F6E;&#x7C7B;&#x5E93;&#xFF1A;">&#x5185;&#x7F6E;&#x7C7B;&#x5E93;&#xFF1A;</h2>
<p><code>wxs</code>&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x5185;&#x7F6E;&#x7684;&#x7C7B;&#x5E93;&#xFF0C;&#x65B9;&#x4FBF;&#x5F00;&#x53D1;&#x8005;&#x8C03;&#x7528;&#x3002;&#x5177;&#x4F53;&#x8BF7;&#x770B;&#xFF1A;<br><code>https://developers.weixin.qq.com/miniprogram/dev/framework/view/wxs/07basiclibrary.html</code>&#x3002;</p>
<h2 id="wxs&#x6848;&#x4F8B;&#xFF1A;">wxs&#x6848;&#x4F8B;&#xFF1A;</h2>
<p>&#x6839;&#x636E;&#x65F6;&#x95F4;&#xFF0C;&#x6765;&#x663E;&#x793A;&#x8DDD;&#x79BB;&#x73B0;&#x5728;&#x7684;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x3002;</p>
<pre><code>    1.&#x5982;&#x679C;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x5C0F;&#x4E8E;1&#x5206;&#x949F;&#x4EE5;&#x5185;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x663E;&#x793A;&#x201C;&#x521A;&#x521A;&#x201D;
    2.&#x5982;&#x679C;&#x662F;&#x5927;&#x4E8E;1&#x5206;&#x949F;&#x5C0F;&#x4E8E;1&#x5C0F;&#x65F6;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x663E;&#x793A;&#x201C;xx&#x5206;&#x949F;&#x524D;&#x201D;
    3.&#x5982;&#x679C;&#x662F;&#x5927;&#x4E8E;1&#x5C0F;&#x65F6;&#x5C0F;&#x4E8E;24&#x5C0F;&#x65F6;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x663E;&#x793A;&#x201C;xx&#x5C0F;&#x65F6;&#x524D;&#x201D;
    4.&#x5982;&#x679C;&#x662F;&#x5927;&#x4E8E;24&#x5C0F;&#x65F6;&#x5C0F;&#x4E8E;30&#x5929;&#x4EE5;&#x5185;&#xFF0C;&#x90A3;&#x4E48;&#x5C31;&#x663E;&#x793A;&#x201C;xx&#x5929;&#x524D;&#x201D;
    5.&#x5426;&#x5219;&#x5C31;&#x662F;&#x663E;&#x793A;&#x5177;&#x4F53;&#x7684;&#x65F6;&#x95F4;2017/10/20 16:15&#x3002;
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-jiu-jie-ff1a-page-dui-xiang.html" class="navigation navigation-prev " aria-label="Previous page: 第九节：Page对象"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../di-san-zhang-ff1a-chang-yong-zu-jian.html" class="navigation navigation-next " aria-label="Next page: 第三章：常用组件"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
